import time

from selenium import webdriver
from selenium.webdriver.common.by import By

driver=webdriver.Firefox()
# 获取网址
driver.get('file:///C:/Users/lenovo/Downloads/index.html')
driver.switch_to.frame(driver.find_element(By.ID,'login'))
driver.switch_to.frame(driver.find_element(By.ID,'register'))
time.sleep(3)
driver.find_element(By.ID,'account').send_keys('admin')
driver.find_element(By.ID,'pwd').send_keys('123456')
driver.find_element(By.ID,'pwd_').send_keys('123456')
driver.find_element(By.ID,'prompt').click()
alert=driver.switch_to.alert
alert.send_keys('炸虾仁')
time.sleep(3)
alert.accept()
# 退出框架
driver.switch_to.default_content()
time.sleep(2)

driver.switch_to.frame(driver.find_element(By.ID,'login'))
driver.find_element(By.NAME,'fname').send_keys('admin')
driver.find_element(By.NAME,'fpwd').send_keys('123456')
time.sleep(2)
driver.find_element(By.XPATH,'/html/body/form/input[3]').click()
alert=driver.switch_to.alert
time.sleep(2)
alert.accept()
time.sleep(5)